/* ---------------------------------------------------------------------------
   (c) Copyright 2006 ActivIdentity, Inc.
   All Rights Reserved.

   This program is an unpublished copyrighted work which is proprietary
   to ActivIdentity. This computer program includes Confidential,
   Proprietary Information and is a Trade Secret of ActivIdentity.
   Any use, disclosure, modification and/or reproduction is prohibited
   unless authorized in writing by ActivIdentity.

   WARNING:  Unauthorized reproduction of this program as well as
   unauthorized preparation of derivative works based upon the
   program or distribution of copies by sale, rental, lease or
   lending are violations of federal copyright laws and state trade
   secret laws, punishable by civil and criminal penalties.
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Disclaimer

   ACTIVIDENTITY MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE 
   CONTENTS OR USE OF THIS SOFTWARE, AND SPECIFICALLY DISCLAIMS ANY EXPRESS
   OR IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR
   PURPOSE. Further, ActivIdentity reserves the right to revise this software
   and to make changes to its content, at any time, without obligation to
   notify any person or entity of such revisions or changes.
   --------------------------------------------------------------------------- */

#ifndef _ANCINIT_H_

#define _ANCINIT_H_


#if (defined WIN32)
	#include <windows.h>
#else 
	#ifndef __UNIX_
	#define __UNIX_

	#define CALLBACK
	#define FALSE 0
	#define TRUE 1
	typedef int BOOL;
	#endif
#endif

#ifdef	__cplusplus 
extern "C" {
#endif

#define IN
#define OUT
#define INOUT

/* size of soft token initialization string frame (with header and footer) */
#define ANCINIT_INIT_FR_LN	10 
/* Max number of frames */ 
#define ANCINIT_INIT_FR_NB	12

/* max size of the device passphrase string  */
#define ANCINIT_PASSPH_LN	256 

/* device string type */
#define ANCINIT_DEVICE_TYPE_GENERIC			1
#define ANCINIT_DEVICE_TYPE_TOKEN_ONE		2
#define ANCINIT_DEVICE_TYPE_PALM_PILOT		3
#define ANCINIT_DEVICE_TYPE_MOBILE_PHONE	4

/* Error codes for various functions */	
enum
{
	ANCINIT_ERR_NOERROR				= 0,/* No Error */
	ANCINIT_ERR_INTERNAL_ERROR		= 1,/* Internal error */
	ANCINIT_ERR_BAD_PARAM			= 2,/* Bad parameter */
	ANCINIT_ERR_SERVICE_NOT_FOUND	= 3,/* Bad or unknown service name */
	ANCINIT_ERR_SDB_INVALID			= 4,/* Bad SDB or bad encryption key */
	ANCINIT_ERR_AUTH_BOTH_MODE_INC	= 5,/* Incoherence between both auth. mode */
	ANCINIT_ERR_BUFF_TOO_SMALL		= 6,/* buffer size too small */
	ANCINIT_ERR_MEMORYALLOCFAILURE	= 7,/* memory allocation failure */
	ANCINIT_ERR_IO_ERROR			= 8,/* input/output error */
	ANCINIT_ERR_WRONG_KEY			= 9,/* bad SDB cipher key */
	ANCINIT_ERR_WRONG_MAC			= 10,/* bad SDB MAC */
	ANCINIT_ERR_BAD_SERIAL_NUMBER	= 11,/* SDB and given serial numbers differ */
};

/* Initialization string format */
typedef char InitStr[ANCINIT_INIT_FR_NB][ANCINIT_INIT_FR_LN + 1];

/* Api functions */
int CALLBACK AncInitGenerateInitString(
		IN const char* pszEncryptionKey,/* SDB encryption KEY */
		INOUT PSDB pDeviceSDB,			/* SDB */
		IN char *pszSerialNumber,		/* device UID  */
		IN unsigned char *pucPassPhrase,/* PassPhrase */
		IN int nPassPhLn,				/* PassPhrase length */
		IN int nTokenType,	/* Device type (for string generation mode) */
		OUT InitStr pszInitStr,			/* manual init. string */
		OUT char *pszDevPassPhrase);	/* Device Converted PassPhrase */

void CALLBACK AncInitGetVersion(
        OUT char *pszVersion,
        OUT unsigned int *punVersion,
        OUT char *pszCopyright, 
        OUT char *pszComment);

#ifdef	__cplusplus
}
#endif

#endif /* ANCINIT_H_ */
